<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link href="./css/api.css" rel="stylesheet"/>
  <link href="./css/element.css" rel="stylesheet"/>
  <link href="./css/base.css" rel="stylesheet"/>
  <title>入职管理</title>
</head>
<body>
  <div id="vm" v-cloak>
    <header class="x-header">
      <i class="el-icon-arrow-left x-closewin-icon" @click="closethiswin"></i>
      <div class="x-header-t">入职管理</div>
    </header>
    <div class="x-assa-form">
      <el-form ref="form" :model="form" :label-position="top">

        <el-form-item label="店面选择">
          <el-select v-model="form.store" placeholder="请选择">
            <el-option :label="item.title" :value="item.id" v-for="item in storedata"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="岗位选择">
          <el-select v-model="form.post" placeholder="请选择">
            <el-option :label="item.title" :value="item.id" v-for="item in jobdata"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="工资级别">
          <el-input v-model="form.money" @input="changemoney"></el-input>
        </el-form-item>

        <div class="x-money-more" v-show="ismoneynomore">超出当前工资限额<span class="x-mmoney-desc">特殊薪酬申请</span></div>

        <el-form-item label="是否保险">
          <el-radio-group v-model="form.Insurance">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>

        <el-form-item label="是否发送短信通知">
          <el-radio-group v-model="form.message">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>

        <el-form-item label="">
          <el-input type="textarea" v-model="form.evaluate"></el-input>
        </el-form-item>
        <!-- <el-form-item>
        </el-form-item> -->
      </el-form>
    </div>
    <div class="x-mana-btn" @click="adminok">提交</div>
  </div>
  <script type="text/javascript" src="./script/vue.js"></script>
  <script type="text/javascript" src="./script/element.js"></script>
  <script type="text/javascript" src="./script/api.js"></script>
  <script type="text/javascript" src="./js/base.js"></script>
  <script>
    apiready = function () {
      var entryid = api.pageParam.id;
      console.log(entryid);
      var entryareaid = api.pageParam.areaid;
      console.log(entryareaid);
      //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          form:{
            store:'',
            post:'',
            money:'',
            Insurance:'',
            message:'',
            evaluate:''
          },
          entryiddata:'',
          entryareadata:'',
          storedata:'',
          jobdata:'',
          ismoneynomore:false
        }
      },
      created:function() {
        var that=this;

      },
      mounted:function(){
        var that=this;
        that.entryiddata = entryid;
        that.entryareadata = entryareaid;
        that.storelist()
        that.joblist()
      },
      methods: {
        //
        changemoney:function(value){
          console.log(value);
          var that = this;
          if(value>=3000){
            that.ismoneynomore = true;
          }else{
            that.ismoneynomore = false;
          }
        },
        // 店面列表
        storelist:function(){
          var that=this;
          api.ajax({
            url:manastore+'storeList',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('usertoken'),
                id:that.entryareadata
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.storedata = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        // 职位列表
        joblist:function(){
          var that=this;
          api.ajax({
            url:manastore+'jobList',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('usertoken')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.jobdata = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        adminok:function(){
          var that=this;
          console.log(that.entryiddata);
          console.log(that.form.store);
          console.log(that.form.post);
          console.log(that.form.Insurance);
          console.log(that.form.message);
          console.log(that.form.evaluate);
          api.ajax({
            url:manastore+'entry',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('usertoken'),
                id:that.entryiddata,
                storeId:that.form.store,
                jobId:that.form.post,
                wages:that.form.money,
                insure:that.form.Insurance ,
                msg:that.form.message
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.sendEvent({
                    name: 'entrysuss',
                    extra: {}
                });
                api.alert({
                    title: '入职成功',
                    msg: '可在在职管理中查看',
                }, function(ret, err) {
                    closethiswin()
                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
    }
  </script>
</body>
</html>
